package io.renren.modules.jxgk.service.impl;

import io.renren.common.utils.Query;
import io.renren.modules.echarts.service.Impl.TeacherPortraitServiceImpl;
import io.renren.modules.jxgk.common.Constant;
import io.renren.modules.jxgk.dao.ClassDiaryTableDao;
import io.renren.modules.jxgk.entity.ClassDiaryEntity;
import io.renren.modules.jxgk.entity.ClassDiaryTeacherSum;
import io.renren.modules.jxgk.entity.TeacherDiary;
import io.renren.modules.jxgk.service.ClassDiaryTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ClassDiaryTableServiceImpl implements ClassDiaryTableService {
    @Autowired
    ClassDiaryTableDao classDiaryDao;
    @Autowired
    TeacherPortraitServiceImpl teacherPortraitService;
    public List<ClassDiaryEntity> queryList(Map<String, Object> map){
        List<ClassDiaryEntity> list=classDiaryDao.queryList(map);
        for(ClassDiaryEntity cde:list)
        {
            if(cde.getTeachingType()!=null) {
                switch (cde.getTeachingType()) {
                    case Constant.TEACHING_TYPE_A:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_A_STR);
                    case Constant.TEACHING_TYPE_B:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_B_STR);
                    case Constant.TEACHING_TYPE_C:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_C_STR);
                }
            }

        }
        return list;
    }
    public int queryTotal(Map<String, Object> map){
        return  classDiaryDao.queryTotal(map);
    }
    public void deleteBatch(String[] termIds){
        classDiaryDao.deleteBatch(termIds);
    }
    public void save(ClassDiaryEntity ste){
        classDiaryDao.save(ste);
    }
    public ClassDiaryEntity queryObject(String index){
        return classDiaryDao.queryObject(index);
    }
    public void update(ClassDiaryEntity ste){
        classDiaryDao.update(ste);
    }

    @Override
    public List<ClassDiaryTeacherSum> queryClassDiaryTeacherSumList(Map<String, Object> map) {
        List<ClassDiaryTeacherSum> cse=classDiaryDao.queryClassDiaryTeacherSumList(map);
        for(int i=0;i<cse.size();i++)
        {
            if(cse.get(i).getCourseAcademicTerm().equals("1"))
            {
                cse.get(i).setCourseAcademicTerm("第一学期");
            }else
            {
                cse.get(i).setCourseAcademicTerm("第二学期");
            }
        }
        return cse;
    }

    @Override
    public int queryClassDiaryTeacherSumTotal(Map<String, Object> map) {
        return classDiaryDao.queryClassDiaryTeacherSumTotal(map);
    }

    @Override
    public List<TeacherDiary> getClassDiaryTableByTeacherAndClassCourse(Map<String, Object> map) {
        List<TeacherDiary> cse=classDiaryDao.getClassDiaryTableByTeacherAndClassCourse(map);
        for(int i=0;i<cse.size();i++)
        {
            if(cse.get(i).getTeachingType()!=null) {
                switch (cse.get(i).getTeachingType()) {
                    case Constant.TEACHING_TYPE_A:
                        cse.get(i).setTeachingTypeStr(Constant.TEACHING_TYPE_A_STR);
                    case Constant.TEACHING_TYPE_B:
                        cse.get(i).setTeachingTypeStr(Constant.TEACHING_TYPE_B_STR);
                    case Constant.TEACHING_TYPE_C:
                        cse.get(i).setTeachingTypeStr(Constant.TEACHING_TYPE_C_STR);
                }
            }
            switch (cse.get(i).getCourseWhichDay())
            {
                case  "1":cse.get(i).setCourseWhichDay("星期一");break;
                case  "2":cse.get(i).setCourseWhichDay("星期二");break;
                case  "3":cse.get(i).setCourseWhichDay("星期三");break;
                case  "4":cse.get(i).setCourseWhichDay("星期四");break;
                case  "5":cse.get(i).setCourseWhichDay("星期五");break;
                case  "6":cse.get(i).setCourseWhichDay("星期六");break;
                case  "7":cse.get(i).setCourseWhichDay("星期天");break;
            }
            int j=Integer.parseInt(cse.get(i).getCourseWhichIndex())+1;
            cse.get(i).setCourseWhichIndex("第"+cse.get(i).getCourseWhichIndex()+"-"+j+"节");
            cse.get(i).setCourseWhichWeek("第"+cse.get(i).getCourseWhichWeek()+"周");

        }
        return cse;
    }

    @Override
    public int getClassDiaryTotalByTeacherAndClassCourse(Query query) {
        return classDiaryDao.getClassDiaryTotalByTeacherAndClassCourse(query);
    }

    @Override
    public List<ClassDiaryEntity> queryChidaoZaotuiList(Map<String, Object> map) {

        String valid=teacherPortraitService.ValidDatesConverter(map);
        //加入肯德基豪华套餐
        map.put("ValidDates",valid);
        List<ClassDiaryEntity> list=classDiaryDao.queryChidaoZaotuiList(map);
        for(ClassDiaryEntity cde:list)
        {
            if(cde.getTeachingType()!=null) {
                switch (cde.getTeachingType()) {
                    case Constant.TEACHING_TYPE_A:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_A_STR);
                    case Constant.TEACHING_TYPE_B:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_B_STR);
                    case Constant.TEACHING_TYPE_C:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_C_STR);
                }
            }

        }
        return list;
    }

    @Override
    public int queryChidaoZaotuiTotal(Map<String, Object> map) {
        String valid=teacherPortraitService.ValidDatesConverter(map);
        //加入肯德基豪华套餐
        map.put("ValidDates",valid);
        return  classDiaryDao.queryChidaoZaotuiTotal(map);
    }

    @Override
    public List<ClassDiaryEntity> queryListChiDaoZaotui(Map<String, Object> params) {
        List<ClassDiaryEntity> list=classDiaryDao.queryListChiDaoZaotui(params);
        for(ClassDiaryEntity cde:list)
        {
            if(cde.getTeachingType()!=null) {
                switch (cde.getTeachingType()) {
                    case Constant.TEACHING_TYPE_A:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_A_STR);
                    case Constant.TEACHING_TYPE_B:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_B_STR);
                    case Constant.TEACHING_TYPE_C:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_C_STR);
                }
            }

        }
        return list;
    }

    @Override
    public List<ClassDiaryEntity> queryListTimeTable(Map<String, Object> params) {
        List<ClassDiaryEntity> list=classDiaryDao.queryListTimeTable(params);
        for(ClassDiaryEntity cde:list)
        {
            if(cde.getTeachingType()!=null) {
                switch (cde.getTeachingType()) {
                    case Constant.TEACHING_TYPE_A:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_A_STR);
                    case Constant.TEACHING_TYPE_B:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_B_STR);
                    case Constant.TEACHING_TYPE_C:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_C_STR);
                }
            }

        }
        return list;
    }

    @Override
    public List<ClassDiaryEntity> queryListChiDaoZaotuiOfOurStudent(Map<String, Object> params) {
        List<ClassDiaryEntity> list=classDiaryDao.queryListChiDaoZaotuiOfOurStudent(params);
        for(ClassDiaryEntity cde:list)
        {
            if(cde.getTeachingType()!=null) {
                switch (cde.getTeachingType()) {
                    case Constant.TEACHING_TYPE_A:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_A_STR);
                    case Constant.TEACHING_TYPE_B:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_B_STR);
                    case Constant.TEACHING_TYPE_C:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_C_STR);
                }
            }

        }
        return list;
    }

    @Override
    public List<ClassDiaryEntity> queryListTimeTableOfOurStudent(Map<String, Object> params) {
        List<ClassDiaryEntity> list=classDiaryDao.queryListTimeTableOfOurStudent(params);
        for(ClassDiaryEntity cde:list)
        {
            if(cde.getTeachingType()!=null) {
                switch (cde.getTeachingType()) {
                    case Constant.TEACHING_TYPE_A:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_A_STR);
                    case Constant.TEACHING_TYPE_B:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_B_STR);
                    case Constant.TEACHING_TYPE_C:
                        cde.setTeachingTypeStr(Constant.TEACHING_TYPE_C_STR);
                }
            }

        }
        return list;
    }
}
